class Money{
    public double money = 19.9;
}
 class S implements Cloneable{
    public int age ;
    public Money m;

    public S(int age) {
        this.age = age;
        this.m =new Money();
    }

    @Override
    public String toString() {
        return "eee{" +
                "age=" + age +
                '}';
    }

     @Override
     protected Object clone() throws CloneNotSupportedException {
         //return super.clone();
         S tmp =(S)super.clone();//克隆了整个对象的内容
         //tmp.m=(Money) this.m.clone();//单独又克隆了对象里的Money类型的成员变量
         return tmp;
     }
 }
public class eee {
    public static void main(String[] args)throws CloneNotSupportedException {
        S s = new S(10);
        S s2 = (S)s.clone();
        System.out.println(s.m.money);
        System.out.println(s2.m.money);
        s2.m.money=99.9;
        System.out.println("==================");
        System.out.println(s.m.money);
        System.out.println(s2.m.money);
    }
}
